﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24CustomerLocationService/Map24CustomerLocationService.php5");



// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


//CustomerLayerIDs to find
$CustomerLayerIDs = '9008';

//CircleFilter
$CircleFilter= new CLCircleFilter();
$CircleFilter->Center= new Coordinate();
$CircleFilter->Center->Longitude = "521.0196";
$CircleFilter->Center->Latitude = "3006.554";
$CircleFilter->Radius = 5000;

//SearchFields
$SearchFields= new Map24CustomerLocation();
$SearchFields->City = 'Frankfurt';

//RequestProperties

//Synchronize Client - show objects on map
$proIdx=0;
$RequestProperty[$proIdx]= new Property();
$RequestProperty[$proIdx]->Key = 'SynchronizeMappingClient';
$RequestProperty[$proIdx]->Value = 'TRUE';

//Exact Search
$proIdx++;
$RequestProperty[$proIdx]= new Property();
$RequestProperty[$proIdx]->Key = 'ExactSearch';
$RequestProperty[$proIdx]->Value = 'FALSE';

//CaseInsensitiv
$proIdx++;
$RequestProperty[$proIdx]= new Property();
$RequestProperty[$proIdx]->Key = 'CaseInsensitiveSearch';
$RequestProperty[$proIdx]->Value = 'TRUE';



// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];


// definition of the request body
$request = new FindCustomerLocationsRequest();
$request->CustomerLayerIDs = array($CustomerLayerIDs);
$request->CircleFilter = $CircleFilter;
$request->SearchFields = $SearchFields;
$request->RequestProperties = RequestProperty;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$maploc = new Map24CustomerLocationService($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $maploc->findCustomerLocations($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "";
$counter = 0;

if( isset($response->Map24CustomerLocations) )
{
	foreach ($response->Map24CustomerLocations as $result)
	{
		$counter++;
		$resultString .= "<div style='border:1px solid black;margin:2px 0px;padding:5px;'>".$counter.". ";
		$resultString .= $result->Name1 . "<br /><br />";
		$resultString .= "Street: " . $result->Street . "<br /><br />";
		$resultString .= "City:" . $result->City . "<br /><br />";
		$resultString .= "Description: " . $result->Description . "<br /><br />";
		$resultString .= "</div>";
	}
}
else
{
	$resultString = "Sorry, nothing found";
}

?>